package com.hedl.practice.diyJava.io.study_operate_zip.test;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
 * ZipInputStream可以读取zip格式的流，ZipOutputStream可以把多份数据写入zip包；
 * 配合FileInputStream和FileOutputStream就可以读写zip文件。
 */
public class Main {
    public static void main(String[] args) throws IOException {
        try(ZipInputStream zip = new ZipInputStream(new FileInputStream("/Users/a101/idea/untitled folder/settings.zip"))){
            ZipEntry entry = null;
            while((entry = zip.getNextEntry()) != null){
                String name = entry.getName();
                if (!entry.isDirectory()){
                    int n;
                    while ((n = zip.read()) != -1){
                        System.out.print((char) n);
                    }
                }
                System.out.println("==="+entry);
            }
        }
    }
}
